Page({
    data: {
      queryRecords: [],
      errorMessage: ''
    },
    onLoad: function() {
      try {
        const queryRecords = wx.getStorageSync('allQueryRecords') || [];
        console.log("Loaded from storage:", queryRecords); // 调试信息
        this.setData({
          queryRecords
        });
      } catch (err) {
        console.error('Failed to retrieve query records:', err);
        this.setData({
          errorMessage: '查询记录加载失败'
        });
      }
    },
    clearQueryRecords: function() {
        // 清空页面上的数据
        this.setData({
          queryRecords: []
        });
    
        // 尝试清空本地缓存
        try {
          wx.removeStorageSync('allQueryRecords');
          console.log("缓存已成功清空");
        } catch(e) {
          console.error("清空缓存失败", e);
        }
      }
  });